<?php

/**
 * contact : 刘经理 19326416371
 * company : 版权所属 四川北星惯牌科技有限公司
 **/

namespace app\common\model;

use think\Model;


class UserTeam extends Model
{

    const STATE_INIT = 0;
    const STATE_SUCCESS = 1;
    const STATE_WRITE_OFF = 2;
    const STATE_WRITE_OUT = 3;
    const PAY_STATUS_INIT = 0;
    const PAY_STATUS_SUCCESS = 1;
    const PAY_STATUS_REFUND = 2;

    const DELETED_STATUS_SUCCESS = 1;
    const DELETED_STATUS_NO = 0;

    const SYSTEM_STATUS_YES = 1;
    const SYSTEM_STATUS_NO = 0;

    

    // 表名
    protected $name = 'user_team';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'state_text',
        'pay_state_text',
        'start_text',
        'follow_text',
        'delete_text'
    ];
    

    
    public function getStateList()
    {
        return ['0' => __('State 0'), '1' => __('State 1'), '2' => __('State 2'), '3' => __('State 3'), '4' => __('State 4')];
    }

    public function getPayStateList()
    {
        return ['0' => __('Pay_state 0'), '1' => __('Pay_state 1'), '2' => __('Pay_state 2')];
    }

    public function getStartList()
    {
        return ['1' => __('Start 1'), '0' => __('Start 0')];
    }

    public function getFollowList()
    {
        return ['1' => __('Follow 1'), '0' => __('Follow 0')];
    }

    public function getDeleteList()
    {
        return ['0' => __('Delete 0'), '1' => __('Delete 1')];
    }


    public function getStateTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['state']) ? $data['state'] : '');
        $list = $this->getStateList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getPayStateTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['pay_state']) ? $data['pay_state'] : '');
        $list = $this->getPayStateList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getStartTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['start']) ? $data['start'] : '');
        $list = $this->getStartList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getFollowTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['follow']) ? $data['follow'] : '');
        $list = $this->getFollowList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getDeleteTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['delete']) ? $data['delete'] : '');
        $list = $this->getDeleteList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function user()
    {
        return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
